﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace WCYCReader.ShareFolder.ViewModel
{
    [DataContract]
    public class ConnectionViewModel : INotifyPropertyChanged
    {
        private string _host;

        private string _name;

        private string _password;

        private string _service;

        private string _user;

        [DataMember]
        public string Details
        {
            get
            {
                return string.Concat("\\\\", this.Host, "\\", this.Service);
            }
        }

        [DataMember]
        public string Host
        {
            get
            {
                return this._host;
            }
            set
            {
                if (value != this._host)
                {
                    this._host = value;
                    this.NotifyPropertyChanged("Host");
                }
            }
        }

        [DataMember]
        public string Name
        {
            get
            {
                return this._name;
            }
            set
            {
                if (value != this._name)
                {
                    this._name = value;
                    this.NotifyPropertyChanged("Name");
                }
            }
        }

        [DataMember]
        public string Password
        {
            get
            {
                return this._password;
            }
            set
            {
                if (value != this._password)
                {
                    this._password = value;
                    this.NotifyPropertyChanged("Password");
                }
            }
        }

        /// <summary>
        /// 共享的文件夹
        /// </summary>
        [DataMember]
        public string Service
        {
            get
            {
                return this._service;
            }
            set
            {
                if (value != this._service)
                {
                    this._service = value;
                    this.NotifyPropertyChanged("Service");
                }
            }
        }

        [DataMember]
        public string User
        {
            get
            {
                return this._user;
            }
            set
            {
                if (value != this._user)
                {
                    this._user = value;
                    this.NotifyPropertyChanged("User");
                }
            }
        }

        private void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged;
            if (propertyChangedEventHandler != null)
            {
                propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
